import React from "react";
import { connect } from 'react-redux'
import { twolevelRouteChange } from "@/redux/actions";


const Main = ({discoverLists, routeChange}) => {
  console.log(discoverLists, 'discoverLists')
  // const gotolink = () => {
  //   console.log('gotolink')
  // }
  return (
    <div>
      Main
      {discoverLists.map((item) => (
        <div onClick={() => routeChange(item.id)} key={item.id}>
          <Child item={item} ></Child>
        </div>
      ))}
    </div>
  );
};

const Child = ({item}) => {
  return <div>{item.isOn ? "isOn" + item.name : item.name}</div>;
};

const mapStateToProps = (state) => {
  return {
    discoverLists: state.routes.twoLevel,
  };
};
const mapDispatchToProps = (dispatch) => {
  return {
    routeChange: (id) => {
      dispatch(twolevelRouteChange(id));
    },
  };
};
export default connect(mapStateToProps, mapDispatchToProps)(Main);
